/*
 * \brief  Timer service
 * \author Norman Feske
 * \date   2006-08-15
 */

/*
 * Copyright (C) 2006-2009 Norman Feske
 * Genode Labs, Feske & Helmuth Systementwicklung GbR
 *
 * This file is part of the Genode OS framework, which is distributed
 * under the terms of the GNU General Public License version 2.
 */

#include <base/env.h>
#include <base/sleep.h>
#include <cap_session/connection.h>

#include "timer_root.h"

using namespace Genode;
using namespace Timer;


/**
 * Main program
 */
int main(int argc, char **argv)
{
	/*
	 * We need to create capabilities for sessions.
	 * Therefore, we request the CAP service.
	 */
	static Cap_connection cap;

	/*
	 * Initialize server entry point that serves the root interface.
	 */
	static Msgbuf<256>             snd_msg, rcv_msg;
	static Server_activation<4096> sa(&snd_msg, &rcv_msg);
	static Server_entrypoint       e(&cap, &sa);

	/*
	 * Use sliced heap to allocate each session component at a separate
	 * dataspace.
	 */
	static Sliced_heap sliced_heap(env()->ram_session(), env()->rm_session());

	/*
	 * Create root interface for timer service
	 */
	static Root_component  timer_root(&sliced_heap, &cap);
	static Root_capability timer_root_cap = Root_capability(e.manage(&timer_root));

	/*
	 * Announce timer service at our parent.
	 */
	env()->parent()->announce(Timer::Session::service_name(), timer_root_cap);

	sleep_forever();
	return 0;
}
